﻿@using System.Data
@using ZoomLa.BLL.Helper
@model ZoomLaCMS.Models.Exam.VM_ExamDetail
@{
    Layout = "~/Areas/User/Views/Shared/_empty.cshtml";
}
@section head{
    <script src="/Plugins/Ueditor/ueditor.config.js" charset="utf-8"></script>
    <script src="/Plugins/Ueditor/ueditor.all.min.js" charset="utf-8"></script>
    <title>评阅试卷</title>
}
@section content{
<form method="post" action="@MVCHelper.GetAction("ExamDetail_Submit",Request)" onsubmit="return PreMark();">
    <div id="pageflag" data-nav="edu" data-ban="ke"></div>
    <div class="container margin_t5">
        <ol class="breadcrumb">
            <li><a href="@Url.Action("Default","")">用户中心</a></li>
            <li><a href="@Url.Action("QuestionManage","Exam")">试题管理</a></li>
            <li class="active">评阅试卷</li>
        </ol>
    </div>
    <div class="container">
        <div class="panel panel-primary" ng-app="app">
            <div class="panel-heading">
                <i class="fa fa-file-text-o"></i>
                <span class="margin_l5">
                    <label id="pname_l"></label>
                </span>
                <span><i class="fa fa-clock-o"></i><span id="time_sp" class="margin_l5" data-time="0">@("用时 " + (Model.answerMod.CDate - Model.answerMod.StartDate).TotalMinutes.ToString("f0") + " 分钟")</span></span>
                <div class="uinfo_div">
                    <div class="input-group">
                        <span class="input-group-addon">学校</span>
                        <input type="text" id="myschool_t" name="myschool_t" disabled="disabled" value="@Model.answerMod.MySchool" class="form-control text_150" />
                    </div>
                    <div class="input-group">
                        <span class="input-group-addon">班级</span>
                        <input type="text" id="myclass_t" name="myclass_t" disabled="disabled" value="@Model.answerMod.MyClass" class="form-control text_150" />
                    </div>
                    <div class="input-group">
                        <span class="input-group-addon">姓名</span>
                        <input type="text" id="uname_t" name="uname_t" disabled="disabled" value="@Model.answerMod.UserName" class="form-control text_150" />
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
            <div class="panel-body" ng-controller="appController">
                @for (int i = 0; i < Model.typeDT.Rows.Count; i++)
                {
                    DataRow dr = Model.typeDT.Rows[i];
                    DataTable dt = Model.GetByType(dr);
                    <div style="margin-top: 5px;">
                        @(StrHelper.ConvertIntegral(i + 1))．@(dr["QName"])（有@(dr["QNum"])小题,共@(dr["TotalScore"])分）
                    </div>
                    <div>@dr["LargeContent"]</div>
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        if (Model.Action.ToLower().Equals("view"))
                        {
                            DataRow row = dt.Rows[j];
                            <div class="item" data-id="@row["p_id"]" id="item_@row["p_id"]">
                                <div class="content"><span>@(j + 1)．@row["P_Title"]</span>@Model.GetContent(row)</div>
                                <div class="submit">
                                    <ul class="submitul">@Model.GetSubmit(row)</ul>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="remark_div margin_t5">
                                    <div class="panel panel-info">
                                        <div class="panel-heading">
                                            <i class="fa fa-file-text-o"></i><span class="margin_l5">教师批阅</span>
                                            <a href="QuestView?ID=@row["Qid"]" target="_blank" class="margin_l5">查看解析</a>
                                        </div>
                                        <div class="panel-body">
                                            <div>
                                                <label>
                                                    <input type="radio" value="1" @(row["IsRight"].ToString().Equals("1") ? "checked=checked":"") name="isright_@row["ID"]" />正确
                                                </label>
                                                <label>
                                                    <input type="radio" value="2" @(row["IsRight"].ToString().Equals("2") ? "checked=checked":"") name="isright_@row["ID"]" />错误
                                                </label>
                                                <div>@Model.GetScoreHtml(row)</div>
                                            </div>
                                            <div>
                                                <div id="remark_@row["ID"]" contenteditable='true' class='answerdiv remark'>@MvcHtmlString.Create(row["Remark"].ToString())</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        }
                    }
                }
            </div>
            <div class="panel-footer text-center">
                <button id="submit_btn" class="btn btn-primary" onclick="Submit_Btn_Click">提交</button>
                <a href="@Url.Action("Papers_System_Manage","Exam")" class="btn btn-primary">返回</a>
            </div>
        </div>
    </div>
    <div>
        <input type="hidden" id="QuestDT_Hid" name="QuestDT_Hid" value="@Model.QuestDT_Hid" />
        <input type="hidden" id="Answer_Hid" name="Answer_Hid" value="@Model.Answer_Hid" />
        <input type="hidden" id="Remark_Hid" name="Remark_Hid" />
    </div>
    <div id="answer_ue_div" style="display: none;">
        <textarea id="editor" style="height: 120px;"></textarea>
        <div id="ue_foot" style="text-align: center; padding: 5px;">
            <input type="button" value="确定" class="btn btn-primary" onclick="LoadContent();" />
            <input type="button" value="关闭" class="btn btn-default" onclick="$('#answer_ue_div').hide();" />
        </div>
    </div>
</form>
}
@section script{
    <script src="/Plugins/Ueditor/kityformula-plugin/addKityFormulaDialog.js"></script>
    <script src="/Plugins/Ueditor/kityformula-plugin/getKfContent.js"></script>
    <script src="/Plugins/Ueditor/kityformula-plugin/defaultFilterFix.js"></script>
    <script src="/JS/Controls/ZL_Array.js"></script>
    <script src="/JS/jquery-ui.min.js"></script>
    <script src="/JS/Plugs/angular.min.js"></script>
    <style type="text/css">
        label { font-weight: normal; }
        .item { border: 1px solid #ddd; padding-left: 20px; padding-top: 5px; text-align: left; }
        .opitem:hover { color: #ff6a00; }
        .opitem p { display: inline-block; }
        .submitul li { float: left; margin-left: 20px; }
        .answerdiv { border: 1px dashed #ddd; height: 50px; color: green; width: 100%; padding: 5px; height: 80px; overflow: auto; }
        .answersp { border-bottom: 1px solid #286090; padding: 5px 15px 3px 15px; color: green; }
        .answersp p { display: inline; }
        #answer_ue_div { width: 500px; position: absolute; top: 300px; right: 30%; border: 1px solid #ddd; box-shadow: 0 4px 20px 1px rgba(0,0,0,0.2); background: #ffffff; cursor: move; }
    </style>
    <script>
        var page={scope:null,addModel:function(name,model){
            page.scope.list[name]=model;
        }};
        var app=angular.module("app",[]).controller("appController",function($scope,$compile){
            page.scope=$scope;
            $scope.list={};
            var idsArr=[];//仅用于显示答案
            @MvcHtmlString.Create(Model.AngularJS)
            if("@Model.Action"=="view")
            {
                var answerArr = JSON.parse($("#Answer_Hid").val());
                //model即一个完形填空的问题集合,问题集合-->问题(答案)-->选项
                for (var i = 0; i < idsArr.length; i++) {
                    var model=$scope.list["filltextblank_"+idsArr[i]];
                    var answer= answerArr.GetByID(idsArr[i],"QID");
                    if(!answer||answer==null||answer==""){return;}
                    answer=JSON.parse(answer.Answer);
                    for (var j = 0; j < model.length; j++) {
                        model[j].answer=answer[j].answer;
                    }
                }
            }
        });
        app.filter(
                'to_trusted', ['$sce', function ($sce) {
                    return function (text) {
                        return $sce.trustAsHtml(text);
                    }
                }]
            );

        var ue, $curAnswer, boundary = "|||", action = "@Model.Action",exTime= parseInt("@Model.ExTime"); force = @(Model.ExTime>0?"true":"false");
        $(function () {
            ue = UE.getEditor('editor', {
                toolbars: [[
                    'bold', 'italic', 'underline', '|', 'fontsize', '|', 'kityformula'
                ]],
                elementPathEnabled: false,wordCount: false
            });
            $("#answer_ue_div").draggable(
                    { handle: '#ue_foot,#edui1_toolbarbox' });
            $(".remark").click(function () {
                $curAnswer = $(this);
                SetContent($curAnswer);
                $("#answer_ue_div").show();
            });
        })
        $(window).scroll(function(){
            var scrollTop = $(this).scrollTop();//已滚动多少
            var nowTop=$("#answer_ue_div").css("top");
            $("#answer_ue_div").css("top",scrollTop+300);
        });
        //var s={id:1,opts:[{op:"A",value:""}]};
    </script>
    <script src="/JS/ICMS/ZL_Exam_Paper.js"></script>
}